﻿using System.Collections.Generic;
using Entitas;
class EnemyStartRoamingSystem : ReactiveSystem<EnemyEntity>
{
    public EnemyStartRoamingSystem(Contexts contexts) : base(contexts.enemy)
    {
        
    }

    protected override void Execute(List<EnemyEntity> entities)
    {
       foreach(var e in entities)
        {
           var rand = new System.Random();
            e.ReplaceRoamingAngle(rand.Next(0, 359));
            e.ReplaceRoamingTimer(1.5f);
        }
    }

    protected override bool Filter(EnemyEntity entity)
    {
        return entity.isRoaming == true;
    }

    protected override ICollector<EnemyEntity> GetTrigger(IContext<EnemyEntity> context)
    {
        return context.CreateCollector(EnemyMatcher.Roaming.Added());
    }
}
